<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2025/5/31
  Time: 下午3:30
  To change this template use File | Settings | File Templates.
--%>
<%--<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>--%>
<%--<%@ page import="java.text.DecimalFormat" %>--%>
<%--<%@ page import="com.shop.service.StudentService" %>--%>
<%--<%@ page import="com.shop.model.Student" %>--%>
<%--<%@ page import="java.util.Date" %>--%>
<%--<%--%>
<%--    // 获取充值金额参数--%>
<%--    double amount = (double) request.getAttribute("amount");--%>
<%--    System.out.println("recharge_success.jsp:16: " + amount);--%>


<%--    // 获取当前余额--%>
<%--    String studentId = request.getParameter("studentId");--%>
<%--    System.out.println("recharge_success.jsp:24: " + studentId);--%>
<%--    StudentService studentService = new StudentService();--%>
<%--    Student student = studentService.search(studentId);--%>
<%--    double balance =student.getMoney() ;--%>


<%--    // 生成随机交易号（模拟）--%>
<%--    String transactionId = "T" + System.currentTimeMillis() + (int)(Math.random() * 1000);--%>

<%--    // 格式化金额显示--%>
<%--    DecimalFormat df = new DecimalFormat("#,##0.00");--%>
<%--    String formattedAmount = df.format(amount);--%>
<%--    String formattedBalance = df.format(balance);--%>
<%--%>--%>
<%--<!DOCTYPE html>--%>
<%--<html>--%>
<%--<head>--%>
<%--    <meta charset="UTF-8">--%>
<%--    <title>充值成功</title>--%>
<%--    <style>--%>
<%--        body {--%>
<%--            font-family: 'Microsoft YaHei', Arial, sans-serif;--%>
<%--            background-color: #f5f5f5;--%>
<%--            margin: 0;--%>
<%--            padding: 0;--%>
<%--            display: flex;--%>
<%--            justify-content: center;--%>
<%--            align-items: center;--%>
<%--            min-height: 100vh;--%>
<%--            color: #333;--%>
<%--        }--%>
<%--        .success-container {--%>
<%--            background: white;--%>
<%--            border-radius: 10px;--%>
<%--            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);--%>
<%--            padding: 40px;--%>
<%--            width: 100%;--%>
<%--            max-width: 500px;--%>
<%--            text-align: center;--%>
<%--        }--%>
<%--        .success-icon {--%>
<%--            color: #52c41a;--%>
<%--            font-size: 72px;--%>
<%--            margin-bottom: 20px;--%>
<%--        }--%>
<%--        h1 {--%>
<%--            color: #52c41a;--%>
<%--            margin-bottom: 30px;--%>
<%--        }--%>
<%--        .amount-display {--%>
<%--            font-size: 28px;--%>
<%--            font-weight: bold;--%>
<%--            color: #1890ff;--%>
<%--            margin: 20px 0;--%>
<%--        }--%>
<%--        .info-card {--%>
<%--            background: #f6ffed;--%>
<%--            border: 1px solid #b7eb8f;--%>
<%--            border-radius: 8px;--%>
<%--            padding: 20px;--%>
<%--            margin: 25px 0;--%>
<%--            text-align: left;--%>
<%--        }--%>
<%--        .info-row {--%>
<%--            display: flex;--%>
<%--            margin-bottom: 12px;--%>
<%--        }--%>
<%--        .info-label {--%>
<%--            width: 100px;--%>
<%--            color: #666;--%>
<%--        }--%>
<%--        .info-value {--%>
<%--            flex: 1;--%>
<%--            font-weight: 500;--%>
<%--        }--%>
<%--        .balance-update {--%>
<%--            font-size: 18px;--%>
<%--            margin: 20px 0;--%>
<%--        }--%>
<%--        .action-buttons {--%>
<%--            margin-top: 30px;--%>
<%--        }--%>
<%--        .btn {--%>
<%--            display: inline-block;--%>
<%--            padding: 12px 24px;--%>
<%--            border-radius: 5px;--%>
<%--            text-decoration: none;--%>
<%--            font-size: 16px;--%>
<%--            margin: 0 10px;--%>
<%--            transition: all 0.3s;--%>
<%--        }--%>
<%--        .btn-primary {--%>
<%--            background: #1890ff;--%>
<%--            color: white;--%>
<%--            border: 1px solid #1890ff;--%>
<%--        }--%>
<%--        .btn-primary:hover {--%>
<%--            background: #40a9ff;--%>
<%--            border-color: #40a9ff;--%>
<%--        }--%>
<%--        .btn-default {--%>
<%--            background: white;--%>
<%--            color: #666;--%>
<%--            border: 1px solid #d9d9d9;--%>
<%--        }--%>
<%--        .btn-default:hover {--%>
<%--            color: #1890ff;--%>
<%--            border-color: #1890ff;--%>
<%--        }--%>
<%--    </style>--%>
<%--</head>--%>
<%--<body>--%>
<%--<div class="success-container">--%>
<%--    <div class="success-icon">✓</div>--%>
<%--    <h1>充值成功</h1>--%>

<%--    <div class="amount-display">+¥<%= formattedAmount %></div>--%>

<%--    <div class="balance-update">--%>
<%--        当前账户余额: <span style="font-weight:bold;color:#1890ff">¥<%= formattedBalance %></span>--%>
<%--    </div>--%>

<%--    <div class="info-card">--%>
<%--        <div class="info-row">--%>
<%--            <div class="info-label">交易金额</div>--%>
<%--            <div class="info-value">¥<%= formattedAmount %></div>--%>
<%--        </div>--%>
<%--        <div class="info-row">--%>
<%--            <div class="info-label">交易时间</div>--%>
<%--            <div class="info-value1"></div>--%>
<%--        </div>--%>
<%--        <div class="info-row">--%>
<%--            <div class="info-label">交易单号</div>--%>
<%--            <div class="info-value"><%= transactionId %></div>--%>
<%--        </div>--%>
<%--        <div class="info-row">--%>
<%--            <div class="info-label">支付方式</div>--%>
<%--            <div class="info-value">--%>
<%--                <%--%>
<%--                    String paymentMethod = request.getParameter("paymentMethod");--%>
<%--                    if("alipay".equals(paymentMethod)) {--%>
<%--                        out.print("支付宝");--%>
<%--                    } else if("wechat".equals(paymentMethod)) {--%>
<%--                        out.print("微信支付");--%>
<%--                    } else {--%>
<%--                        out.print("未知");--%>
<%--                    }--%>
<%--                %>--%>
<%--            </div>--%>
<%--        </div>--%>
<%--        <div class="info-row">--%>
<%--            <div class="info-label">交易状态</div>--%>
<%--            <div class="info-value" style="color:#52c41a">已完成</div>--%>
<%--        </div>--%>
<%--    </div>--%>

<%--    <div class="action-buttons">--%>
<%--        <a href="edit_profile.jsp?studentId=<%=studentId%>" class="btn btn-primary">查看账户</a>--%>
<%--        <a href="welcome.jsp?studentId=<%=studentId%>" class="btn btn-default">返回首页</a>--%>
<%--    </div>--%>
<%--</div>--%>
<%--<script>--%>
<%--    const date = new Date();--%>
<%--    const chineseTime = date.toLocaleString('zh-CN', {--%>
<%--        year: 'numeric',--%>
<%--        month: '2-digit',--%>
<%--        day: '2-digit',--%>
<%--        hour: '2-digit',--%>
<%--        minute: '2-digit',--%>
<%--        second: '2-digit',--%>
<%--        hour12: false // 24小时制--%>
<%--    });--%>
<%--    document.querySelector('.info-value1').textContent = chineseTime;--%>
<%--</script>--%>
<%--</body>--%>
<%--</html>--%>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.text.DecimalFormat" %>
<%@ page import="com.shop.service.StudentService" %>
<%@ page import="com.shop.model.Student" %>
<%@ page import="java.util.Date" %>
<%@ page import="com.shop.service.IStudentService" %>
<%
    double amount = (double) request.getAttribute("amount");
    String studentId = request.getParameter("studentId");
    IStudentService istudentService = new StudentService();
    Student student = istudentService.search(studentId);
    double balance = student.getMoney();
    String transactionId = "T" + System.currentTimeMillis() + (int)(Math.random() * 1000);
    DecimalFormat df = new DecimalFormat("#,##0.00");
    String formattedAmount = df.format(amount);
    String formattedBalance = df.format(balance);
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>充值成功</title>
    <style>
        :root {
            --primary-color: #4361ee;
            --secondary-color: #3a0ca3;
            --success-color: #4cc9f0;
            --light-color: #f8f9fa;
            --dark-color: #212529;
            --border-radius: 12px;
            --box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
            --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
        }

        body {
            background: linear-gradient(135deg, #f5f7ff 0%, #e6f1ff 100%);
            color: var(--dark-color);
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            padding: 20px;
        }

        .success-container {
            background: white;
            border-radius: var(--border-radius);
            box-shadow: var(--box-shadow);
            padding: 50px;
            width: 100%;
            max-width: 560px;
            text-align: center;
            position: relative;
            overflow: hidden;
        }

        .success-container::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 6px;
            background: linear-gradient(90deg, var(--primary-color), var(--success-color));
        }

        .success-icon {
            width: 100px;
            height: 100px;
            margin: 0 auto 25px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, rgba(76, 201, 240, 0.1) 0%, rgba(67, 97, 238, 0.1) 100%);
            border-radius: 50%;
            position: relative;
        }

        .success-icon::after {
            content: '✓';
            font-size: 48px;
            color: var(--success-color);
            font-weight: bold;
        }

        h1 {
            color: var(--success-color);
            margin-bottom: 30px;
            font-size: 32px;
            font-weight: 600;
            position: relative;
            padding-bottom: 15px;
        }

        h1::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 50%;
            transform: translateX(-50%);
            width: 80px;
            height: 3px;
            background: linear-gradient(90deg, var(--primary-color), var(--success-color));
            border-radius: 3px;
        }

        .amount-display {
            font-size: 40px;
            font-weight: 700;
            margin: 30px 0;
            background: linear-gradient(90deg, var(--primary-color), var(--success-color));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            position: relative;
            display: inline-block;
        }

        .amount-display::before {
            content: '+';
            position: absolute;
            left: -25px;
        }

        .balance-update {
            font-size: 20px;
            margin: 30px 0;
            color: #555;
        }

        .balance-update span {
            font-weight: 600;
            color: var(--primary-color);
        }

        .info-card {
            background: linear-gradient(135deg, rgba(76, 201, 240, 0.05) 0%, rgba(67, 97, 238, 0.05) 100%);
            border: 1px solid rgba(67, 97, 238, 0.15);
            border-radius: var(--border-radius);
            padding: 25px;
            margin: 35px 0;
            text-align: left;
        }

        .info-row {
            display: flex;
            margin-bottom: 15px;
            align-items: center;
        }

        .info-label {
            width: 100px;
            color: #666;
            font-size: 15px;
        }

        .info-value {
            flex: 1;
            font-weight: 500;
            font-size: 16px;
        }

        .info-value1 {
            flex: 1;
            font-weight: 500;
            font-size: 16px;
        }

        .status-badge {
            display: inline-block;
            padding: 4px 12px;
            background: rgba(76, 201, 240, 0.1);
            color: var(--success-color);
            border-radius: 20px;
            font-size: 14px;
            font-weight: 600;
        }

        .action-buttons {
            margin-top: 40px;
            display: flex;
            justify-content: center;
            gap: 15px;
        }

        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 14px 28px;
            border-radius: var(--border-radius);
            text-decoration: none;
            font-size: 16px;
            font-weight: 500;
            transition: var(--transition);
            min-width: 160px;
        }

        .btn-primary {
            background: linear-gradient(90deg, var(--primary-color), var(--success-color));
            color: white;
            box-shadow: 0 4px 15px rgba(67, 97, 238, 0.3);
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(67, 97, 238, 0.4);
        }

        .btn-default {
            background: white;
            color: var(--primary-color);
            border: 1px solid var(--primary-color);
        }

        .btn-default:hover {
            background: rgba(67, 97, 238, 0.05);
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(67, 97, 238, 0.1);
        }

        @media (max-width: 600px) {
            .success-container {
                padding: 30px 20px;
            }

            h1 {
                font-size: 28px;
            }

            .amount-display {
                font-size: 32px;
            }

            .action-buttons {
                flex-direction: column;
                gap: 12px;
            }

            .btn {
                width: 100%;
            }

            .info-row {
                flex-direction: column;
                align-items: flex-start;
            }

            .info-label {
                margin-bottom: 5px;
                width: 100%;
            }
        }
    </style>
</head>
<body>
<div class="success-container">
    <div class="success-icon"></div>
    <h1>充值成功</h1>

    <div class="amount-display">¥<%= formattedAmount %></div>

    <div class="balance-update">
        当前账户余额: <span>¥<%= formattedBalance %></span>
    </div>

    <div class="info-card">
        <div class="info-row">
            <div class="info-label">交易金额</div>
            <div class="info-value">¥<%= formattedAmount %></div>
        </div>
        <div class="info-row">
            <div class="info-label">交易时间</div>
            <div class="info-value1"></div>
        </div>
        <div class="info-row">
            <div class="info-label">交易单号</div>
            <div class="info-value"><%= transactionId %></div>
        </div>
        <div class="info-row">
            <div class="info-label">支付方式</div>
            <div class="info-value">
                <%
                    String paymentMethod = request.getParameter("paymentMethod");
                    if("alipay".equals(paymentMethod)) {
                        out.print("支付宝");
                    } else if("wechat".equals(paymentMethod)) {
                        out.print("微信支付");
                    } else {
                        out.print("未知");
                    }
                %>
            </div>
        </div>
        <div class="info-row">
            <div class="info-label">交易状态</div>
            <div class="info-value"><span class="status-badge">已完成</span></div>
        </div>
    </div>

    <div class="action-buttons">
        <a href="edit_profile.jsp?studentId=<%=studentId%>" class="btn btn-primary">查看账户</a>
        <a href="welcome.jsp?studentId=<%=studentId%>" class="btn btn-default">返回首页</a>
    </div>
</div>
<script>
    const date = new Date();
    const chineseTime = date.toLocaleString('zh-CN', {
        year: 'numeric',
        month: '2-digit',
        day: '2-digit',
        hour: '2-digit',
        minute: '2-digit',
        second: '2-digit',
        hour12: false
    });
    document.querySelector('.info-value1').textContent = chineseTime;
</script>
</body>
</html>
